(function($) {
	
	$.multipleSelector = $.multipleSelector || {};
	
	$.extend($.multipleSelector,{

		/**
		 * 待选 移至 已选
		 */
		sourceToDesti : function(){
			var $this = this,config = this[0].config;
			
			var $multipleSelectDesti = $("#"+config.multipleSelectDestiId),
				$multipleSelectSource = $("#"+config.multipleSelectSourceId);
			
			var optionDatas = [];
			$multipleSelectSource.find("option:selected").each(function(index,elm){
				var $elm = $(elm);
				$elm.clone().appendTo($multipleSelectDesti).data("objectData",$elm.data("objectData"));
				optionDatas.push($elm.data("objectData"));
			});
			$multipleSelectSource.find("option:selected").remove();
			//待选 移至 已选 后事件
			if($.isFunction(config.afterSourceToDestiFunc)){
				config.afterSourceToDestiFunc.call(config,optionDatas);
			}
		},
		
		/**
		 * 已选 移至 待选
		 */
		destiToSource : function(){
			var $this = this,config = this[0].config;
			
			var $multipleSelectDesti = $("#"+config.multipleSelectDestiId),
				$multipleSelectSource = $("#"+config.multipleSelectSourceId);
			
			var optionDatas = [];
			$multipleSelectDesti.find("option:selected").each(function(index,elm){
				var $elm = $(elm);
				$elm.clone().appendTo($multipleSelectSource).data("objectData",$elm.data("objectData"));
				optionDatas.push($elm.data("objectData"));
			});
			
			$multipleSelectDesti.find("option:selected").remove();
			//已选 移至 待选 后事件
			if($.isFunction(config.afterDestiToSourceFunc)){
				config.afterDestiToSourceFunc.call(config,optionDatas);
			}
		},
		
		/**
		 * 已选 全部移至 待选
		 */
		destiAllToSource : function(){
			var $this = this,config = this[0].config;
			
			var $multipleSelectDesti = $("#"+config.multipleSelectDestiId),
				$multipleSelectSource = $("#"+config.multipleSelectSourceId);
			
			$multipleSelectDesti.find("option").each(function(index,elm){
				var $elm = $(elm);
				$elm.clone().appendTo($multipleSelectSource).data("objectData",$elm.data("objectData"));
			});
			$multipleSelectDesti.find("option").remove();
		},
		
		/**
		 * 获取待选下拉 选中的value
		 */
		getSourceSelectedValues : function(){
			var $this = this,config = this[0].config;
			var values = $.SelectUtils.getSelectedOptionValues("#"+config.multipleSelectSourceId);
			return values;
		},
		
		/**
		 * 获取已选下拉 选中的value
		 */
		getDestiSelectedValues : function(){
			var $this = this,config = this[0].config;
			var values = $.SelectUtils.getSelectedOptionValues("#"+config.multipleSelectDestiId);
			return values;
		},
		
		/**
		 * 获取待选下拉 选中的data
		 */
		getSourceSelectedDatas : function(){
			var $this = this,config = this[0].config;
			var datas = $.SelectUtils.getSelectedOptionDatas("#"+config.multipleSelectSourceId);
			return datas;
		},
		
		/**
		 * 获取已选下拉 选中的data
		 */
		getDestiSelectedDatas : function(){
			var $this = this,config = this[0].config;
			var datas = $.SelectUtils.getSelectedOptionDatas("#"+config.multipleSelectDestiId);
			return datas;
		},
		
		/**
		 * 获取待选下拉 所有的value
		 */
		getSourceAllValues : function(){
			var $this = this,config = this[0].config;
			var values = $.SelectUtils.getAllOptionValues("#"+config.multipleSelectSourceId);
			return values;
		},
		
		/**
		 * 获取已选下拉 所有的value
		 */
		getDestiAllValues : function(){
			var $this = this,config = this[0].config;
			var values = $.SelectUtils.getAllOptionValues("#"+config.multipleSelectDestiId);
			return values;
		},
		
		/**
		 * 获取待选下拉 所有的Data
		 */
		getSourceAllDatas : function(){
			var $this = this,config = this[0].config;
			var datas = $.SelectUtils.getAllOptionDatas("#"+config.multipleSelectSourceId);
			return datas;
		},
		
		/**
		 * 获取已选下拉 所有的Data
		 */
		getDestiAllDatas : function(){
			var $this = this,config = this[0].config;
			var datas = $.SelectUtils.getAllOptionDatas("#"+config.multipleSelectDestiId);
			return datas;
		},
		
		/**
		 * 设置待选下拉的数据
		 */
		setSourceDatas : function(datas,optionConfig){
			var $this = this,config = this[0].config;
			$.SelectUtils.setOptions(datas,$.extend({},{selector:"#"+config.multipleSelectSourceId,addData:true},optionConfig));
		},
		
		/**
		 * 设置已选下拉的数据
		 */
		setDestiDatas : function(datas,optionConfig){
			var $this = this,config = this[0].config;
			$.SelectUtils.setOptions(datas,$.extend({},{selector:"#"+config.multipleSelectDestiId,addData:true},optionConfig));
		}
		
	});
})(jQuery);